Operations endpoints: version info #931
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an Operations /version endpoint and wires it into node startup logs/tests so fault-tolerance tests can discover and validate version info similarly to /metrics.
Changes:
- Add
/versionhandler initialization incommon/operations.Systemand a helper to build the/versionURL. - Log the
/versionendpoint URL on startup for router/consensus/batcher/assembler nodes. - Add test utilities and new fault-tolerance tests that fetch
/versionand assert the returnedCommitSHAandVersion.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
common/operations/system.go |
Registers and initializes a /version handler; adds a URL helper. |
node/router/router.go |
Logs the /version endpoint URL at startup. |
node/consensus/consensus.go |
Logs the /version endpoint URL at startup. |
node/batcher/batcher.go |
Logs the /version endpoint URL at startup. |
node/assembler/assembler.go |
Logs the /version endpoint URL at startup. |
testutil/network_utils.go |
Adds helpers to capture /version URL and fetch/unmarshal version info. |
test/faulttolerance/router_test.go |
Adds a fault-tolerance test validating router /version output. |
test/faulttolerance/consensus_test.go |
Adds a fault-tolerance test validating consenter /version output. |
test/faulttolerance/batcher_test.go |
Adds a fault-tolerance test validating batcher /version output. |
test/faulttolerance/assembler_test.go |
Adds a fault-tolerance test validating assembler /version output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func FetchVersionInfoValue(t *testing.T, re *regexp.Regexp, url string) *operations.VersionInfoHandler { | ||
| resp, err := http.Get(url) | ||
| require.NoError(t, err) | ||
|
|
||
| defer resp.Body.Close() | ||
|
|
||
| body, err := io.ReadAll(resp.Body) | ||
| require.NoError(t, err) | ||
|
|
||
| t.Log(string(body)) | ||
|
|
||
| // Find all matches | ||
| matches := re.FindAllString(string(body), -1) | ||
|
|
||
| if len(matches) > 0 { | ||
| val := &operations.VersionInfoHandler{} | ||
| err := json.Unmarshal([]byte(matches[0]), val) | ||
| require.NoError(t, err) | ||
| return val | ||
| } | ||
|
|
||
| return nil | ||
| } |
c809877 to
23619dc
Compare
23619dc to
7f31a97
Compare
7f31a97 to
82be09d
Compare
82be09d to
80531a7
Compare
| } | ||
| // swagger:operation GET /version operations version | ||
| // --- | ||
| // summary: Returns the orderer or peer version and the commit SHA on which the release was created. |
| if val == nil { | ||
| return false | ||
| } | ||
| return val.CommitSHA == metadata.CommitSHA && val.Version == metadata.Version |
There was a problem hiding this comment.
please t.logf the version and build infor
| require.GreaterOrEqual(t, testutil.FetchPrometheusMetricValue(t, blocksCountRe, url), 2) | ||
| } | ||
|
|
||
| // TestRunArmaNetworkAndGetAssemblerVersionInfo tests that the assembler's version info endpoint is up and returns the correct version information after the assembler is started. |
There was a problem hiding this comment.
We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.
| }) | ||
| } | ||
|
|
||
| // TestRunArmaNetworkAndGetBatcherVersionInfo tests that the batcher's version info endpoint is up and returns the correct version information after the batcher is started. |
There was a problem hiding this comment.
We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.
| }) | ||
| } | ||
|
|
||
| // TestRunArmaNetworkAndGetConsenterVersionInfo tests that the consenter's version info endpoint is up and returns the correct version information after the consenter is started. |
There was a problem hiding this comment.
We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.
| }) | ||
| } | ||
|
|
||
| // TestRunArmaNetworkAndGetRouterVersionInfo tests that the router's version info endpoint is up and returns the correct version information after the router is started. |
There was a problem hiding this comment.
We don't need to spin 4 different networks to test the /version service.
Start one network and test /healthz, /version in one test on all componets.
| } | ||
|
|
||
| func (s *System) initializeVersionInfoHandler() { | ||
| versionInfo := &VersionInfoHandler{ |
There was a problem hiding this comment.
This is coming from fabric-x-orderer/internal/cryptogen/metadata... not the right place IMO
80531a7 to
46baee3
Compare
Signed-off-by: Genady Gurevich <genadyg@il.ibm.com>
46baee3 to
bfcbf7b
Compare
issue: #45